﻿using AutoMapper;
using BasicInformation.API.Application.Command.FuelCostsCommand;
using BasicInformation.Domain;
using BasicInformation.Infrastructure.Interface;
using MediatR;
using PublicCommon;

namespace BasicInformation.API.Application.CommandHandler.FuelCostsCommandHandler
{
    public class FuelCostsCreateCommandHandler : IRequestHandler<FuelCostsCreateCommand, int>
    {
        private readonly IFuelCostsRepository fuelCostsRepository;
        private readonly IMapper mapper;

        public FuelCostsCreateCommandHandler(IFuelCostsRepository fuelCostsRepository, IMapper mapper)
        {
            this.fuelCostsRepository = fuelCostsRepository;
            this.mapper = mapper;
        }
        public async Task<int> Handle(FuelCostsCreateCommand request, CancellationToken cancellationToken)
        {
            var info= mapper.Map<FuelCosts>(request);
            return await fuelCostsRepository.Create(info);
        }
    }
}
